﻿using Microsoft.Extensions.DependencyInjection;

namespace Order.MicroService.Api.Config
{
    public class CorsConfig
    {
        public static void RegisterCors(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy", builder =>
                {
                    builder.AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials()
                    //.WithOrigins("http://192.168.8.103:8300", "http://192.168.8.103:8301");
                    //AllowAnyOrigin()允许所有来源请求，不安全；WithOrigins()允许特定来源的CORS请求
                    //.AllowAnyOrigin()
                    .WithOrigins("http://192.168.8.103:8005");
                });
            });
        }
    }
}
